<?php
class EquipmentType extends ORDataObject {
	const MEDICINE_FUNCTIONAL_TYPE = 0;
	const MATERIAL_FUNCTIONAL_TYPE = 1;
	
	var $equipment_type_id	= '';
	var $vi_name	=	'';
	var $en_name	=	'';
	
	var $_table 		= 'equipment_type';
	var $_key 			= 'equipment_type_id';
	var $_internalName	= 'EquipmentType';
	const EQUIPMENT_ID = 9;
	function EquipmentType() {
		parent::ORDataObject();
	}
	
	function getAll(){
		$field	=	L10nHelper::getLocale();
		$field	=	L10nHelper::changeField($field, "name");
		$ds = new Datasource_sql();
		$sql = array(
					'cols'	=> "equipment_type_id, $field",
					'from'	=> " $this->_table"
					);
		$ds->setup($this->_db, $sql);
		return $ds->toArray();
	}
	
	/**
	 * Get all values of medicine type. 
	 * @return array of ['equipment_type_id', 'name']
	 */
	function getMedicineTypeList() {
        $field  =   L10nHelper::getLocale();
        $field	=	L10nHelper::changeField($field, "name");
        $ds = new Datasource_sql();
        $sql = array(
                    'cols'  => "equipment_type_id, $field as name",
                    'from'  => " $this->_table",
                    'where' => " functional_type = " . EquipmentType::MEDICINE_FUNCTIONAL_TYPE
                    );
        $ds->setup($this->_db, $sql);
        return $ds->toArray('equipment_type_id', 'name');
	}

}
?>